package com.jic.market.mapper.overlay;

import com.jic.market.entity.overlay.OverlayPromotionInfo;
import com.jic.market.impl.rest.discountamount.model.PromotionAmountModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 叠加规则活动信息表
 *
 * @author : seven
 * @version : v1.0.0
 * @email : 774329481@qq.com
 * @since : 2020-03-20 04:52:58
 */
@Repository
public interface OverlayPromotionInfoMapper {

    long insert(OverlayPromotionInfo overlayPromotionInfo);

    long delete(@Param("overlayId") String overlayId);

    long update(OverlayPromotionInfo overlayPromotionInfo);

    OverlayPromotionInfo queryByPrimaryKey(Long id);

    List<OverlayPromotionInfo> query(OverlayPromotionInfo overlayPromotionInfo);

    List<OverlayPromotionInfo> queryPage(@Param("startIndex") int startIndex, @Param("limit") int limit, @Param("overlayPromotionInfo") OverlayPromotionInfo overlayPromotionInfo);

    long queryPageCount(OverlayPromotionInfo overlayPromotionInfo);

    @Select("select * from market_overlay_promotion_info where overlay_id=#{overlayId} and overlay_group_id=#{overlayGroupId} and delete_flag='0'")
    List<OverlayPromotionInfo> queryOverlayPromotionByOverlayGroupId(@Param("overlayId")String overlayId,@Param("overlayGroupId")String overlayGroupId);

    @Update("update market_overlay_promotion_info set delete_flag='1' where overlay_id=#{overlayId} " +
            "and overlay_group_id=#{overlayGroupId} and promotion_id=#{promotionId} and prom_type=#{promType} and delete_flag='0' ")
    long deleteOverlayPromotionInfo(@Param("overlayId")String overlayId,
                                    @Param("overlayGroupId")String overlayGroupId,
                                    @Param("promotionId")String promotionId,
                                    @Param("promType")String promType);

    String queryOverlayGroupIdByPromotionIds(@Param("promotionIds")List<String> promotionIds);

}